package com.gzx.plugin.tjzy.xxljob;

import cn.hutool.core.date.DateUtil;
import com.gzx.plugin.tjzy.modular.excel.imports.service.GzxExcelImportService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import vip.xiaonuo.common.tenant.TenantContext;

@Component
@RequiredArgsConstructor
public class SampleXxlJob {

    private final GzxExcelImportService excelImportService;

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
//    @CommonCheckInstanceOnline
    public void demoJobHandler() {
        XxlJobHelper.log("XXL-JOB, Hello World." + DateUtil.now());
        System.out.println("XXL-JOB, Hello World." + DateUtil.now());
        try {
            TenantContext.disableTenantFilter();
            excelImportService.excelProcess();
        } finally {
            TenantContext.enableTenantFilter();
        }
    }
}
